package hxg.stream.characterStream;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 使用字符缓冲流读取文件
 * @author HeXiangGuang
 * @create 2021-06-28 23:19
 */
public class Demo5 {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("d:\\writer.txt");
        BufferedReader br = new BufferedReader(fr);
        //第一种方式读取
//        char[] buf = new char[1024];
//        int count = 0;
//        while ((count = br.read(buf)) != -1){
//            System.out.println(new String(buf,0,count));
//        }
        //第二种方式读取，一行行的读取
        String line = null;
        while ((line = br.readLine()) !=null){
            System.out.println(line);
        }
        br.close();
        fr.close();
    }
}
